<template>


    <a-modal :title="title" :width="600" :destroyOnClose="true" :maskClosable="false"
             :visible="visible" @cancel="handleCancel" @ok="onSubmit">

        <a-radio-group @change="(e)=>{ checkedId=e.target.value}">
            <a-row :gutter="[16,16]">
                <a-col :span="8" v-for="(item,index) in  wxmpTagOPT" :key="index">
                    <a-radio :value="item.value">
                        {{item.name}}
                    </a-radio>
                </a-col>
            </a-row>
        </a-radio-group>


    </a-modal>

</template>
<script>
    import {wxmpTagDict} from '../../../../util/internal.api'

    export default {
        props: ['tagType'],
        data() {
            return {
                loading: false, //按钮Loading
                title: "标签设置",
                wxmpTagOPT: [],
                visible: true, //modal 显示状态
                checkedId: null,
            };
        },
        methods: {

            async init() {
                this.title = this.tagType === 'add' ? "批量加标签" : "批量去标签";
                await wxmpTagDict().then(res => this.wxmpTagOPT = res)
            },

            //关闭弹窗
            handleCancel() {
                this.visible = false;
                this.$emit('closeModal', {
                    render: false
                });
            },


            //完成监听
            onSubmit() {
                const _this = this;
                this.$confirm({
                    title: this.tagType === "add" ? "确定要为选定用户添加标签吗？" : "确定要为选定用户移除标签吗？",
                    onOk() {
                        let obj = {render: true, data: {tagId: _this.checkedId, type: _this.tagType}}
                        _this.$emit('closeModal', obj);
                    },
                    onCancel() {
                        _this.$emit('closeModal', {render: false});
                    }

                })


            },


        },

        created() {
            this.init();


        }
    };
</script>
